local key = KEYS[1]

local rate = tobumber(ARGV[1])
-- 窗口大小
local expiration = tobumber(ARGV[2])
local now = tobumber(ARGV[3])

local boundary = now - size

redis.call('ZREMRANGEBYSCORE', key, '-inf', boundary)
local cnt = redis.call('ZCOUNT', key, '-inf', '+inf')

if cnt > rate then
    return "true"
else
    redis.call("ZADD",key,now,now)
    redis.call("EXPIRE", key, expiration)
    return "false"
end




